package com.lbank.spiderflow.core.utils;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.TypeReference;

public class JSONHelper {

    public static String toJSON(Object obj) {
        return JSON.toJSONString(obj);
    }

    public static <T> T fromJSON(String json, Class<T> clazz) {
        return JSON.parseObject(json, clazz);
    }

    public static <T> T fromJSON(String json, TypeReference<T> typeReference) {
        return JSON.parseObject(json, typeReference, JSONReader.Feature.IgnoreAutoTypeNotMatch);
    }
}
